import React, { useState, useEffect } from 'react'
import { Table, Tag, Space, message,lookup,} from 'antd';
import style from './style.module.css'
import { Input } from 'antd';

import { management, delele } from '@/api'
function CreateLivePage() {
  const columns = [
    {
      title: '配置',
      dataIndex: 'allocation',
      key: 'name',
      render: text => <a>{text}</a>,
    },
    {
      title: '秒杀时段',
      dataIndex: 'time frame',
      key: 'age',
    },
    {
      title: '商品图片',
      dataIndex: 'img',
      render: img => <img style={{ width: 35, height: 35 }} src={img} alt="" />
    },
    {
      title: '活动标题',
      key: 'tags',
      dataIndex: 'introduce',

    },
    {
      title: '活动介绍',
      dataIndex: 'title',
      key: 'address',
    },
    {
      title: '秒杀价',
      dataIndex: 'Original',
      key: 'address',
    },
    {
      title: '限量',
      dataIndex: 'Seconds to bargain',
      key: 'address',
    },
    {
      title: '限量剩余',
      dataIndex: 'remain',
      key: 'address',
    },
    {
      title: '秒杀状态',
      dataIndex: 'limited',
      key: 'address',
    },
    {
      title: 'Action',
      key: 'action',
      render: (text, record) => (
        <Space size="middle">
          <a>编辑</a>
          <a onClick={() => { del(record.id) }}>删除</a>
        </Space>
      ),
    },
  ];
  const [shopdata, setshopdata] = useState([])
  useEffect(() => {
    getShopList()
  }, [])
  //渲染数据
  const getShopList = () => {
    management().then(res => {
      console.log(res)
      setshopdata(res.data.data)
    })
  }
  //删除数据
  const del = (id) => {
    console.log(id)
    delele({ id }).then(res => {
      console.log(res)
      getShopList()
    })
    //删除成功提示
    message.success('删除成功！');
  }
  //模糊搜索
  
  return <div className={style.skillbox}>
    <div className={style.skillheader}>
    <Input placeholder="请输入关键字" className={style.ipt}/>
   
    </div>
    <div className={style.skillcontent}>
    <Table columns={columns} dataSource={shopdata} />
    </div>

  </div>;
}

export default CreateLivePage;
